package cn.iocoder.yudao.module.infra.dal.mysql.infocolumncollect;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;
import cn.iocoder.yudao.module.infra.dal.dataobject.infocolumncollect.InfoColumnCollectDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.infra.controller.admin.infocolumncollect.vo.*;

/**
 * 基础资料表元素汇总 Mapper
 *
 * @author lry
 */
@Mapper
public interface InfoColumnCollectMapper extends BaseMapperX<InfoColumnCollectDO> {

    default PageResult<InfoColumnCollectDO> selectPage(InfoColumnCollectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InfoColumnCollectDO>()
                .eqIfPresent(InfoColumnCollectDO::getTableId, reqVO.getTableId())
                .likeIfPresent(InfoColumnCollectDO::getColumnName, reqVO.getColumnName())
                .eqIfPresent(InfoColumnCollectDO::getDataType, reqVO.getDataType())
                .eqIfPresent(InfoColumnCollectDO::getColumnComment, reqVO.getColumnComment())
                .eqIfPresent(InfoColumnCollectDO::getNullable, reqVO.getNullable())
                .eqIfPresent(InfoColumnCollectDO::getPrimaryKey, reqVO.getPrimaryKey())
                .eqIfPresent(InfoColumnCollectDO::getAutoIncrement, reqVO.getAutoIncrement())
                .eqIfPresent(InfoColumnCollectDO::getOrdinalPosition, reqVO.getOrdinalPosition())
                .eqIfPresent(InfoColumnCollectDO::getJavaType, reqVO.getJavaType())
                .eqIfPresent(InfoColumnCollectDO::getJavaField, reqVO.getJavaField())
                .eqIfPresent(InfoColumnCollectDO::getDictType, reqVO.getDictType())
                .eqIfPresent(InfoColumnCollectDO::getExample, reqVO.getExample())
                .eqIfPresent(InfoColumnCollectDO::getCreateOperation, reqVO.getCreateOperation())
                .eqIfPresent(InfoColumnCollectDO::getUpdateOperation, reqVO.getUpdateOperation())
                .eqIfPresent(InfoColumnCollectDO::getListOperation, reqVO.getListOperation())
                .eqIfPresent(InfoColumnCollectDO::getListOperationCondition, reqVO.getListOperationCondition())
                .eqIfPresent(InfoColumnCollectDO::getListOperationResult, reqVO.getListOperationResult())
                .eqIfPresent(InfoColumnCollectDO::getHtmlType, reqVO.getHtmlType())
                .betweenIfPresent(InfoColumnCollectDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InfoColumnCollectDO::getId));
    }

    default List<InfoColumnCollectDO> selectList(InfoColumnCollectExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InfoColumnCollectDO>()
                .eqIfPresent(InfoColumnCollectDO::getTableId, reqVO.getTableId())
                .likeIfPresent(InfoColumnCollectDO::getColumnName, reqVO.getColumnName())
                .eqIfPresent(InfoColumnCollectDO::getDataType, reqVO.getDataType())
                .eqIfPresent(InfoColumnCollectDO::getColumnComment, reqVO.getColumnComment())
                .eqIfPresent(InfoColumnCollectDO::getNullable, reqVO.getNullable())
                .eqIfPresent(InfoColumnCollectDO::getPrimaryKey, reqVO.getPrimaryKey())
                .eqIfPresent(InfoColumnCollectDO::getAutoIncrement, reqVO.getAutoIncrement())
                .eqIfPresent(InfoColumnCollectDO::getOrdinalPosition, reqVO.getOrdinalPosition())
                .eqIfPresent(InfoColumnCollectDO::getJavaType, reqVO.getJavaType())
                .eqIfPresent(InfoColumnCollectDO::getJavaField, reqVO.getJavaField())
                .eqIfPresent(InfoColumnCollectDO::getDictType, reqVO.getDictType())
                .eqIfPresent(InfoColumnCollectDO::getExample, reqVO.getExample())
                .eqIfPresent(InfoColumnCollectDO::getCreateOperation, reqVO.getCreateOperation())
                .eqIfPresent(InfoColumnCollectDO::getUpdateOperation, reqVO.getUpdateOperation())
                .eqIfPresent(InfoColumnCollectDO::getListOperation, reqVO.getListOperation())
                .eqIfPresent(InfoColumnCollectDO::getListOperationCondition, reqVO.getListOperationCondition())
                .eqIfPresent(InfoColumnCollectDO::getListOperationResult, reqVO.getListOperationResult())
                .eqIfPresent(InfoColumnCollectDO::getHtmlType, reqVO.getHtmlType())
                .betweenIfPresent(InfoColumnCollectDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InfoColumnCollectDO::getId));
    }

    default void deleteListByTableId(Long tableId) {
        delete(new LambdaQueryWrapperX<InfoColumnCollectDO>()
                .eq(InfoColumnCollectDO::getTableId, tableId));
    }

    default List<InfoColumnCollectDO> getInfoColumnCollectListByTableId(Long tableId) {
        return selectList(new LambdaQueryWrapperX<InfoColumnCollectDO>()
                .eq(InfoColumnCollectDO::getTableId, tableId)
                .orderByAsc(InfoColumnCollectDO::getId));
    }
}
